<!DOCTYPE html>



  


<html class="theme-next muse use-motion" lang="zh-Hans">
<head>
  <meta charset="UTF-8"/>
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1"/>
<meta name="theme-color" content="#222">



  
  
    
    
  <script src="/lib/pace/pace.min.js?v=1.0.2"></script>
  <link href="/lib/pace/pace-theme-center-minimal.min.css?v=1.0.2" rel="stylesheet">







<meta http-equiv="Cache-Control" content="no-transform" />
<meta http-equiv="Cache-Control" content="no-siteapp" />
















  
  
  <link href="/lib/fancybox/source/jquery.fancybox.css?v=2.1.5" rel="stylesheet" type="text/css" />







<link href="/lib/font-awesome/css/font-awesome.min.css?v=4.6.2" rel="stylesheet" type="text/css" />

<link href="/css/main.css?v=5.1.3" rel="stylesheet" type="text/css" />


  <link rel="apple-touch-icon" sizes="180x180" href="/images/apple-touch-icon.png?v=5.1.3">


  <link rel="icon" type="image/png" sizes="32x32" href="http://7xqdz8.com1.z0.glb.clouddn.com/avatar.png?v=5.1.3">


  <link rel="icon" type="image/png" sizes="16x16" href="http://7xqdz8.com1.z0.glb.clouddn.com/avatar.png?v=5.1.3">


  <link rel="mask-icon" href="/images/logo.svg?v=5.1.3" color="#222">





  <meta name="keywords" content="Java,Windows,经验," />










<meta name="description" content="前言此文将介绍如何搭建JNI开发环境，包括Windows下C++编译器MinGW和Eclipse下CDT插件的安装两个部分。">
<meta property="og:type" content="article">
<meta property="og:title" content="JNI开发之环境搭建">
<meta property="og:url" content="/2016/02/11/jni_env/index.html">
<meta property="og:site_name" content="一路前行">
<meta property="og:description" content="前言此文将介绍如何搭建JNI开发环境，包括Windows下C++编译器MinGW和Eclipse下CDT插件的安装两个部分。">
<meta property="og:image" content="http://7xqdz8.com1.z0.glb.clouddn.com/160211downloadpage1.png">
<meta property="og:image" content="http://7xqdz8.com1.z0.glb.clouddn.com/160211downloadpage2.png">
<meta property="og:image" content="http://7xqdz8.com1.z0.glb.clouddn.com/160211gui.png">
<meta property="og:image" content="http://7xqdz8.com1.z0.glb.clouddn.com/160211downloadpage4.png">
<meta property="og:image" content="http://7xqdz8.com1.z0.glb.clouddn.com/160211downloadpage3.png">
<meta property="og:image" content="http://7xqdz8.com1.z0.glb.clouddn.com/160211downloadpage5.png">
<meta property="og:image" content="http://7xqdz8.com1.z0.glb.clouddn.com/160211install1.png">
<meta property="og:image" content="http://7xqdz8.com1.z0.glb.clouddn.com/160211install2.png">
<meta property="og:updated_time" content="2016-02-11T15:13:34.659Z">
<meta name="twitter:card" content="summary">
<meta name="twitter:title" content="JNI开发之环境搭建">
<meta name="twitter:description" content="前言此文将介绍如何搭建JNI开发环境，包括Windows下C++编译器MinGW和Eclipse下CDT插件的安装两个部分。">



<script type="text/javascript" id="hexo.configurations">
  var NexT = window.NexT || {};
  var CONFIG = {
    root: '/',
    scheme: 'Muse',
    version: '5.1.3',
    sidebar: {"position":"left","display":"post","offset":12,"b2t":false,"scrollpercent":false,"onmobile":false},
    fancybox: true,
    tabs: true,
    motion: {"enable":true,"async":false,"transition":{"post_block":"fadeIn","post_header":"slideDownIn","post_body":"slideDownIn","coll_header":"slideLeftIn","sidebar":"slideUpIn"}},
    duoshuo: {
      userId: '0',
      author: '博主'
    },
    algolia: {
      applicationID: '',
      apiKey: '',
      indexName: '',
      hits: {"per_page":10},
      labels: {"input_placeholder":"Search for Posts","hits_empty":"We didn't find any results for the search: ${query}","hits_stats":"${hits} results found in ${time} ms"}
    }
  };
</script>



  <link rel="canonical" href="/2016/02/11/jni_env/"/>





  <title>JNI开发之环境搭建 | 一路前行</title>
  





  <script type="text/javascript">
    var _hmt = _hmt || [];
    (function() {
      var hm = document.createElement("script");
      hm.src = "https://hm.baidu.com/hm.js?8193f7e44c62cdda245d5f109196c830";
      var s = document.getElementsByTagName("script")[0];
      s.parentNode.insertBefore(hm, s);
    })();
  </script>




</head>

<body itemscope itemtype="http://schema.org/WebPage" lang="zh-Hans">

  
  
    
  

  <div class="container sidebar-position-left page-post-detail">
    <div class="headband"></div>

    <header id="header" class="header" itemscope itemtype="http://schema.org/WPHeader">
      <div class="header-inner"><div class="site-brand-wrapper">
  <div class="site-meta ">
    

    <div class="custom-logo-site-title">
      <a href="/"  class="brand" rel="start">
        <span class="logo-line-before"><i></i></span>
        <span class="site-title">一路前行</span>
        <span class="logo-line-after"><i></i></span>
      </a>
    </div>
      
        <p class="site-subtitle">Always believe that some thing wonderful is about to happen.</p>
      
  </div>

  <div class="site-nav-toggle">
    <button>
      <span class="btn-bar"></span>
      <span class="btn-bar"></span>
      <span class="btn-bar"></span>
    </button>
  </div>
</div>

<nav class="site-nav">
  

  
    <ul id="menu" class="menu">
      
        
        <li class="menu-item menu-item-home">
          <a href="/" rel="section">
            
              <i class="menu-item-icon fa fa-fw fa-home"></i> <br />
            
            首页
          </a>
        </li>
      
        
        <li class="menu-item menu-item-categories">
          <a href="/categories/" rel="section">
            
              <i class="menu-item-icon fa fa-fw fa-th"></i> <br />
            
            分类
          </a>
        </li>
      
        
        <li class="menu-item menu-item-archives">
          <a href="/archives/" rel="section">
            
              <i class="menu-item-icon fa fa-fw fa-archive"></i> <br />
            
            归档
          </a>
        </li>
      
        
        <li class="menu-item menu-item-about">
          <a href="/about/" rel="section">
            
              <i class="menu-item-icon fa fa-fw fa-user"></i> <br />
            
            关于
          </a>
        </li>
      

      
    </ul>
  

  
</nav>



 </div>
    </header>

    <main id="main" class="main">
      <div class="main-inner">
        <div class="content-wrap">
          <div id="content" class="content">
            

  <div id="posts" class="posts-expand">
    

  

  
  
  

  <article class="post post-type-normal" itemscope itemtype="http://schema.org/Article">
  
  
  
  <div class="post-block">
    <link itemprop="mainEntityOfPage" href="/2016/02/11/jni_env/">

    <span hidden itemprop="author" itemscope itemtype="http://schema.org/Person">
      <meta itemprop="name" content="Voyager">
      <meta itemprop="description" content="">
      <meta itemprop="image" content="http://7xqdz8.com1.z0.glb.clouddn.com/avatar.png">
    </span>

    <span hidden itemprop="publisher" itemscope itemtype="http://schema.org/Organization">
      <meta itemprop="name" content="一路前行">
    </span>

    
      <header class="post-header">

        
        
          <h1 class="post-title" itemprop="name headline">JNI开发之环境搭建</h1>
        

        <div class="post-meta">
          <span class="post-time">
            
              <span class="post-meta-item-icon">
                <i class="fa fa-calendar-o"></i>
              </span>
              
                <span class="post-meta-item-text">发表于</span>
              
              <time title="创建于" itemprop="dateCreated datePublished" datetime="2016-02-11T23:00:00+08:00">
                2016-02-11
              </time>
            

            

            
          </span>

          
            <span class="post-category" >
            
              <span class="post-meta-divider">|</span>
            
              <span class="post-meta-item-icon">
                <i class="fa fa-folder-o"></i>
              </span>
              
                <span class="post-meta-item-text">分类于</span>
              
              
                <span itemprop="about" itemscope itemtype="http://schema.org/Thing">
                  <a href="/categories/Java/" itemprop="url" rel="index">
                    <span itemprop="name">Java</span>
                  </a>
                </span>

                
                
              
            </span>
          

          
            
          

          
          

          

          

          

        </div>
      </header>
    

    
    
    
    <div class="post-body" itemprop="articleBody">

      
      

      
        <h1 id="u524D_u8A00"><a href="#u524D_u8A00" class="headerlink" title="前言"></a>前言</h1><p>此文将介绍如何搭建JNI开发环境，包括Windows下C++编译器MinGW和Eclipse下CDT插件的安装两个部分。<br><a id="more"></a></p>
<h1 id="MinGW_u5B89_u88C5"><a href="#MinGW_u5B89_u88C5" class="headerlink" title="MinGW安装"></a>MinGW安装</h1><blockquote>
<p><strong>MinGW介绍:</strong><br>MinGW（Minimalist GNU for Windows），又称mingw32，是将GCC编译器和GNU Binutils移植到Win32平台下的产物，包括一系列头文件（Win32API）、库和可执行文件。<br>另有可用于产生32位及64位Windows可执行文件的MinGW-w64项目，是从原本MinGW产生的分支。如今已经独立发展。</p>
</blockquote>
<!--more-->
<h2 id="u5B89_u88C5_u5668_u5728_u7EBF_u5B89_u88C5_u65B9_u5F0F"><a href="#u5B89_u88C5_u5668_u5728_u7EBF_u5B89_u88C5_u65B9_u5F0F" class="headerlink" title="安装器在线安装方式"></a>安装器在线安装方式</h2><h3 id="u4E0B_u8F7D_u5B89_u88C5_u5668"><a href="#u4E0B_u8F7D_u5B89_u88C5_u5668" class="headerlink" title="下载安装器"></a>下载安装器</h3><ul>
<li>首先进入官网<a href="http://www.mingw.org/" target="_blank" rel="external">MinGW官网</a></li>
</ul>
<p><img src="http://7xqdz8.com1.z0.glb.clouddn.com/160211downloadpage1.png" alt="官网首页"></p>
<ul>
<li>进入下载界面，<strong>此处注意如果你的电脑如果是64位一定要下载64位版本</strong>，否则后面生成的dll文件是32位的。(笔者被坑哭::&gt;_&lt;::)</li>
</ul>
<p><img src="http://7xqdz8.com1.z0.glb.clouddn.com/160211downloadpage2.png" alt="下载界面"></p>
<h3 id="u4F7F_u7528_u5B89_u88C5_u5668_u5B89_u88C5"><a href="#u4F7F_u7528_u5B89_u88C5_u5668_u5B89_u88C5" class="headerlink" title="使用安装器安装"></a>使用安装器安装</h3><blockquote>
<p>此处需要科学上网</p>
</blockquote>
<p>双击打开 <code>mingw-w64-install.exe</code>一步步安装即可。<br><img src="http://7xqdz8.com1.z0.glb.clouddn.com/160211gui.png" alt="GUI界面"></p>
<h2 id="u79BB_u7EBF_u5B89_u88C5_28_u63A8_u8350_29"><a href="#u79BB_u7EBF_u5B89_u88C5_28_u63A8_u8350_29" class="headerlink" title="离线安装(推荐)"></a>离线安装(推荐)</h2><ul>
<li>进入下载地址页面后，依次进入以下目录<br><code>Home / Toolchains targetting Win64 /
Personal Builds / mingw-builds /
5.3.0 / threads-posix / seh</code>下载Zip离线包</li>
</ul>
<p><img src="http://7xqdz8.com1.z0.glb.clouddn.com/160211downloadpage4.png" alt="下载界面"></p>
<p><img src="http://7xqdz8.com1.z0.glb.clouddn.com/160211downloadpage3.png" alt="离线安装包"></p>
<ul>
<li>下载后解压到 <code>E:\MinGW</code>并配置PATH环境变量到bin目录层</li>
</ul>
<blockquote>
<p>两种方法均需要配置环境变量，到 <code>E:\MinGW\bin</code>即可。</p>
</blockquote>
<h1 id="CDT_u5B89_u88C5"><a href="#CDT_u5B89_u88C5" class="headerlink" title="CDT安装"></a>CDT安装</h1><h2 id="u4E0B_u8F7D"><a href="#u4E0B_u8F7D" class="headerlink" title="下载"></a>下载</h2><p>在Eclipse官网<a href="https://eclipse.org/cdt/downloads.php" target="_blank" rel="external">CDT区</a>下载CDT插件。<br><img src="http://7xqdz8.com1.z0.glb.clouddn.com/160211downloadpage5.png" alt="CDT下载界面"></p>
<h2 id="u5B89_u88C5"><a href="#u5B89_u88C5" class="headerlink" title="安装"></a>安装</h2><ul>
<li>打开Eclipse，选择 <code>Help</code>-&gt;<code>Install New Software</code><br><img src="http://7xqdz8.com1.z0.glb.clouddn.com/160211install1.png" alt="窗口选项"></li>
<li>点击Add添加插件，Name随意，地址点击Archive选择插件压缩包，最后注意去掉在线update勾选框<br><img src="http://7xqdz8.com1.z0.glb.clouddn.com/160211install2.png" alt="安装界面"></li>
<li>接下来一路Next即可。</li>
</ul>
<h1 id="u7ED3_u8BED"><a href="#u7ED3_u8BED" class="headerlink" title="结语"></a>结语</h1><p>至此，环境基本搭建完成，但是要进行JNI开发还需要一些步骤，我将在后续的博客中给出，请持续关注。</p>

      
    </div>
    
    
    

    

    
      <div>
        <div style="padding: 10px 0; margin: 20px auto; width: 90%; text-align: center;">
  <div></div>
  <button id="rewardButton" disable="enable" onclick="var qr = document.getElementById('QR'); if (qr.style.display === 'none') {qr.style.display='block';} else {qr.style.display='none'}">
    <span>打赏</span>
  </button>
  <div id="QR" style="display: none;">

    
      <div id="wechat" style="display: inline-block">
        <img id="wechat_qr" src="http://7xqdz8.com1.z0.glb.clouddn.com/pay_weixin.png" alt="Voyager 微信支付"/>
        <p>微信支付</p>
      </div>
    

    
      <div id="alipay" style="display: inline-block">
        <img id="alipay_qr" src="http://7xqdz8.com1.z0.glb.clouddn.com/pay_alipay.jpg" alt="Voyager 支付宝"/>
        <p>支付宝</p>
      </div>
    

    

  </div>
</div>

      </div>
    

    

    <footer class="post-footer">
      
        <div class="post-tags">
          
            <a href="/tags/Java/" rel="tag"># Java</a>
          
            <a href="/tags/Windows/" rel="tag"># Windows</a>
          
            <a href="/tags/经验/" rel="tag"># 经验</a>
          
        </div>
      

      
      
      

      
        <div class="post-nav">
          <div class="post-nav-next post-nav-item">
            
              <a href="/2016/02/09/accessibility/" rel="next" title="Accessibility辅助功能的使用">
                <i class="fa fa-chevron-left"></i> Accessibility辅助功能的使用
              </a>
            
          </div>

          <span class="post-nav-divider"></span>

          <div class="post-nav-prev post-nav-item">
            
              <a href="/2016/02/17/SelectorNoUse/" rel="prev" title="Selector无效的几种情况">
                Selector无效的几种情况 <i class="fa fa-chevron-right"></i>
              </a>
            
          </div>
        </div>
      

      
      
    </footer>
  </div>
  
  
  
  </article>



    <div class="post-spread">
      
    </div>
  </div>


          </div>
          


          
  


        </div>
        
          
  
  <div class="sidebar-toggle">
    <div class="sidebar-toggle-line-wrap">
      <span class="sidebar-toggle-line sidebar-toggle-line-first"></span>
      <span class="sidebar-toggle-line sidebar-toggle-line-middle"></span>
      <span class="sidebar-toggle-line sidebar-toggle-line-last"></span>
    </div>
  </div>

  <aside id="sidebar" class="sidebar">
    
    <div class="sidebar-inner">

      

      
        <ul class="sidebar-nav motion-element">
          <li class="sidebar-nav-toc sidebar-nav-active" data-target="post-toc-wrap">
            文章目录
          </li>
          <li class="sidebar-nav-overview" data-target="site-overview-wrap">
            站点概览
          </li>
        </ul>
      

      <section class="site-overview-wrap sidebar-panel">
        <div class="site-overview">
          <div class="site-author motion-element" itemprop="author" itemscope itemtype="http://schema.org/Person">
            
              <img class="site-author-image" itemprop="image"
                src="http://7xqdz8.com1.z0.glb.clouddn.com/avatar.png"
                alt="Voyager" />
            
              <p class="site-author-name" itemprop="name">Voyager</p>
              <p class="site-description motion-element" itemprop="description">Android Developer</p>
          </div>

          <nav class="site-state motion-element">

            
              <div class="site-state-item site-state-posts">
              
                <a href="/archives/">
              
                  <span class="site-state-item-count">41</span>
                  <span class="site-state-item-name">日志</span>
                </a>
              </div>
            

            
              
              
              <div class="site-state-item site-state-categories">
                <a href="/categories/index.html">
                  <span class="site-state-item-count">8</span>
                  <span class="site-state-item-name">分类</span>
                </a>
              </div>
            

            
              
              
              <div class="site-state-item site-state-tags">
                
                  <span class="site-state-item-count">10</span>
                  <span class="site-state-item-name">标签</span>
                
              </div>
            

          </nav>

          

          <div class="links-of-author motion-element">
            
              
                <span class="links-of-author-item">
                  <a href="https://github.com/a-voyager" target="_blank" title="GitHub">
                    
                      <i class="fa fa-fw fa-github"></i>GitHub</a>
                </span>
              
                <span class="links-of-author-item">
                  <a href="mailto:w19961009@126.com" target="_blank" title="E-Mail">
                    
                      <i class="fa fa-fw fa-envelope"></i>E-Mail</a>
                </span>
              
                <span class="links-of-author-item">
                  <a href="https://weibo.com/u/2306071720" target="_blank" title="微博">
                    
                      <i class="fa fa-fw fa-weibo"></i>微博</a>
                </span>
              
            
          </div>

          
          

          
          

          

        </div>
      </section>

      
      <!--noindex-->
        <section class="post-toc-wrap motion-element sidebar-panel sidebar-panel-active">
          <div class="post-toc">

            
              
            

            
              <div class="post-toc-content"><ol class="nav"><li class="nav-item nav-level-1"><a class="nav-link" href="#u524D_u8A00"><span class="nav-number">1.</span> <span class="nav-text">前言</span></a></li><li class="nav-item nav-level-1"><a class="nav-link" href="#MinGW_u5B89_u88C5"><span class="nav-number">2.</span> <span class="nav-text">MinGW安装</span></a><ol class="nav-child"><li class="nav-item nav-level-2"><a class="nav-link" href="#u5B89_u88C5_u5668_u5728_u7EBF_u5B89_u88C5_u65B9_u5F0F"><span class="nav-number">2.1.</span> <span class="nav-text">安装器在线安装方式</span></a><ol class="nav-child"><li class="nav-item nav-level-3"><a class="nav-link" href="#u4E0B_u8F7D_u5B89_u88C5_u5668"><span class="nav-number">2.1.1.</span> <span class="nav-text">下载安装器</span></a></li><li class="nav-item nav-level-3"><a class="nav-link" href="#u4F7F_u7528_u5B89_u88C5_u5668_u5B89_u88C5"><span class="nav-number">2.1.2.</span> <span class="nav-text">使用安装器安装</span></a></li></ol></li><li class="nav-item nav-level-2"><a class="nav-link" href="#u79BB_u7EBF_u5B89_u88C5_28_u63A8_u8350_29"><span class="nav-number">2.2.</span> <span class="nav-text">离线安装(推荐)</span></a></li></ol></li><li class="nav-item nav-level-1"><a class="nav-link" href="#CDT_u5B89_u88C5"><span class="nav-number">3.</span> <span class="nav-text">CDT安装</span></a><ol class="nav-child"><li class="nav-item nav-level-2"><a class="nav-link" href="#u4E0B_u8F7D"><span class="nav-number">3.1.</span> <span class="nav-text">下载</span></a></li><li class="nav-item nav-level-2"><a class="nav-link" href="#u5B89_u88C5"><span class="nav-number">3.2.</span> <span class="nav-text">安装</span></a></li></ol></li><li class="nav-item nav-level-1"><a class="nav-link" href="#u7ED3_u8BED"><span class="nav-number">4.</span> <span class="nav-text">结语</span></a></li></ol></div>
            

          </div>
        </section>
      <!--/noindex-->
      

      

    </div>
  </aside>


        
      </div>
    </main>

    <footer id="footer" class="footer">
      <div class="footer-inner">
        <div class="copyright">&copy; 2015 &mdash; <span itemprop="copyrightYear">2017</span>
  <span class="with-love">
    <i class="fa fa-user"></i>
  </span>
  <span class="author" itemprop="copyrightHolder">WuHaojie</span>

  
</div>









        







        
      </div>
    </footer>

    
      <div class="back-to-top">
        <i class="fa fa-arrow-up"></i>
        
      </div>
    

  </div>

  

<script type="text/javascript">
  if (Object.prototype.toString.call(window.Promise) !== '[object Function]') {
    window.Promise = null;
  }
</script>









  


  











  
  <script type="text/javascript" src="/lib/jquery/index.js?v=2.1.3"></script>

  
  <script type="text/javascript" src="/lib/fastclick/lib/fastclick.min.js?v=1.0.6"></script>

  
  <script type="text/javascript" src="/lib/jquery_lazyload/jquery.lazyload.js?v=1.9.7"></script>

  
  <script type="text/javascript" src="/lib/velocity/velocity.min.js?v=1.2.1"></script>

  
  <script type="text/javascript" src="/lib/velocity/velocity.ui.min.js?v=1.2.1"></script>

  
  <script type="text/javascript" src="/lib/fancybox/source/jquery.fancybox.pack.js?v=2.1.5"></script>

  
  <script type="text/javascript" src="/lib/canvas-nest/canvas-nest.min.js"></script>


  


  <script type="text/javascript" src="/js/src/utils.js?v=5.1.3"></script>

  <script type="text/javascript" src="/js/src/motion.js?v=5.1.3"></script>



  
  

  
  <script type="text/javascript" src="/js/src/scrollspy.js?v=5.1.3"></script>
<script type="text/javascript" src="/js/src/post-details.js?v=5.1.3"></script>



  


  <script type="text/javascript" src="/js/src/bootstrap.js?v=5.1.3"></script>



  


  




	





  





  








  





  

  

  

  

  

  

</body>
</html>
